    $(function () {
        qaImgShowFn();
        lazyUserImage();
        var topicId = $('#id').val();
        var classesId = $('#classesId').val();
        var requestURL = $('#requestURL').val();

    $('body')
        .on('click', '#topic-report', function () {
            isLogin(function () {
                popupTopicReport();
            });
        })
        .on('click', '#topic-thumbs-up', function () {
            topicThumbsUp();
        }).on('click', '#classes-topic-publish', function () {//发表话题
            window.location = baseloaction + '/web/classes/topic/initPublish?classesId=' + classesId;
        }).on('click', '#classes-join', function () {//加入班级
            isLogin(function () {
                classesJoin(classesId,requestURL);
            })
        });

    // 举报弹窗
    function popupTopicReport() {
        var _ele = $('#topicReportEle');
        layer.open({
            type: 1,
            title: '<b>举报此话题</b>',
            closeBtn: 1,
            area: ['500px', '280px'],
            shadeClose: false,
            skin: 'lay_ppComment__wrap',
            content: _ele,
            btn: [' 提交 ', ' 取消 '],
            yes: function (index, layero) {
                var reportType = layero.find('input[name=reportType]:checked').val();
                var context = layero.find('#report-context').text();
                submitTopicReport(reportType, context);
            }
        })
    }

    // 提交话题举报
    function submitTopicReport(type, content) {
        var params = {
            'topicId': topicId,
            'type': type,
            'content': content
        };
        params = JSON.stringify(params);
        $.ajax({
            url: baseloaction + '/web/classes/topic/saveTopicReport',
            data: params,
            dataType: 'json',
            type: 'post',
            contentType: 'application/json;charset=utf-8',
            success: function (response) {
                if (response.success) {
                    layer.closeAll();
                    icModale(0, '', response.message);
                } else {
                    icModale(0, '', response.message);
                }
            },
            error: function () {
                icModale(0, '', '系统繁忙，请稍候再试');
            }
        })
    }

    // 点赞话题
    function topicThumbsUp() {
        isLogin(function () {
            $.ajax({
                url: baseloaction + '/web/classes/topic/updateTopicLike',
                data: {'topicId': topicId},
                dataType: 'json',
                success: function (response) {
                    icModale(0, '', response.message);
                    if (response.success) {
                        $("#likeNum").html(response.entity.likeNum+'人点赞');
                        if(response.entity.likeFlag){
                            $('.icon-love_fill').removeClass('hide');
                            $('.icon-xihuan').addClass('hide');
                            var context = "<li id=\"user-like-"+response.entity.userId+"\"><img src=\""+response.entity.avatar+"\" width=\"32\" height=\"32\" class=\"img-circle lazy vam\"></li>";
                            var ul = $("ul.wg-face-list");
                            $(ul).find('span').remove();
                            $(ul).append(context);
                            $(ul).append('<span></span>');
                        }else {
                            $('.icon-love_fill').addClass('hide');
                            $('.icon-xihuan').removeClass('hide');
                            $('#user-like-'+response.entity.userId).remove();
                        }
                        if(response.entity.likeNum > 10){
                            $("ul.wg-face-list").find('span').html('等'+response.entity.likeNum+'人点过赞');
                        }
                    }
                    lazyUserImage();
                },
                error: function () {
                    icModale(0, '', '系统繁忙，请稍候再试');
                }
            })
        })
    }
});
//话题主干图片放大方法
function qaImgShowFn() {
    var images = $('.topic_content img');
    if(images.length>0){
        for(var i=0;i<images.length;i++){
            $(images[i]).css({'cursor':'url('+staticPath+'/front/web/v3/img/default/big.cur),auto','max-width': '100%'});
        };
    }
    layer.photos({
        photos: '.topic_content,.question-content-img__wrap',//选择器
        anim: -1,
        tab: function(pic, layero){}
    });
}
